﻿@model IEnumerable<WebSoftSeo.Models.News>
@using WebSoftSeo.Models
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    News banner = ViewBag.Banner;
    List<News> Index = ViewBag.NewsIndex as List<News>;
    List<News> LastNews = ViewBag.LastNews as List<News>;
    int counts = ViewBag.count;
    int count = counts / 2;
    if(counts %2!=0)
    {
        count = count + 1;
    }
}
<style>
    .giveMeEllipsis
    {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4; /* number of lines to show */
        line-height: 2; /* fallback */
        max-height: 100px; /* fallback */
    }
</style>
<div class="wrapfilterbgBlog">
    <div class="container">
        <div class="wrapfilter1">
            <div class="divfilterL">
                <h4 class="h1title">@banner.CategoriesName</h4>
                <p>@banner.Summary</p>
            </div>
            <div class="divfilterR">
                <p>Bản tin đăng kí</p>
                <div class="formSub">
                    <button type="button" class="buttonSub">Submit</button>
                    <input type="text" class="testBoxsub" placeholder="Adress Email">
                    <input type="text" class="testBoxsub" placeholder="Full name">
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<!-- Content Blog -->
<div class="wrapBlogContent">
    <div class="container">
        <!-- blogContentL -->
        <div class="blogContentL">
            @if (Index != null)
            {
                foreach (var index in Index)
                {
                    DateTime dt = (DateTime)index.CreatedDate;
                    string date = dt.ToString("HH:mm    dd/MM/yyyy");
                <div class="col1">
                    <h4><a href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(index.Title), id = index.NewsID })">@index.Title </a></h4>
                    <p class="namedate">@date</p>
                    <div class="testBlog">
                        <img class="img-responsive" src="~/Images/News/@index.ImagePath">
                       @* @Html.Raw(index.ShortDescription)*@
                        <p >                           
                            @Html.Raw(index.ShortDescription)
                        </p>
                    </div>
                    <div class="social">
                        <a href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(index.Title), id = index.NewsID })">Xem thêm</a>
                        <div class="divSocial">
                            <img src="~/data/h2.jpg"></div>
                        <div class="clearfix"></div>
                    </div>
                </div>
                }
            }
            @{
                int pagenew = 0;
                if (Request["page"] != null)
                {
                    pagenew = Convert.ToInt32(Request["page"]);
                }

            }

            <div class="clearfix"></div>
            <div class="prev-next">
                <ul>
                    <li><a href="@Url.Content("~/News/Index/?page=" + ((pagenew - 1) < 1 ? pagenew : (pagenew - 1)))">
                        <p>Previous</p>
                    </a></li>
                    @for (int i = 1; i <= count; i++)
                    {
                        if (Request["page"] != null && Convert.ToInt32(Request["Page"]) == i)
                        {
                        <li><a class="active" href="@Url.Content("~/News/Index/?page=" + i)">@i</a></li>
                        }
                        else
                        {
                             <li><a href="@Url.Content("~/News/Index/?page=" + i)">@i</a></li>
                        }
                    }


                    <li><a href="@Url.Content("~/News/Index/?page=" + ((pagenew + 1) > count ? pagenew : (pagenew + 1)))">Next</a></li>
                </ul>
                <div class="clearfix"></div>
            </div>
        </div>
        <!-- End blogContentL -->
        <!-- blogContentR -->
        <div class="blogContentR">
            <div class="listCate">
                <h2>Tin mới</h2>
                <ul class="listBlog slide8">
                    @if (LastNews != null)
                    {
                        foreach (var last in LastNews)
                        {
                            
                        <li class="slides">                        
                                @if(last.ImagePath != null)
                                {
                                  <div class="imgBlog"><a href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(last.Title), id = last.NewsID })">
                                        <div class="maskN"></div>
                                    <img src="~/Images/News/@last.ImagePath" style="height:70px"></a></div>
                                    <div class="testNew">
                                        <h2><a class="colortest1" href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(last.Title), id = last.NewsID })">@last.Title</a></h2>
                                        <p class="giveMeEllipsis">@last.ShortDescription</p>
                                    </div>

                                }
                            else
                            {
                                    <div class="testNewNon">
                                        <h2><a class="colortest1" href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(last.Title), id = last.NewsID })">@last.Title</a></h2>
                                        <p class="giveMeEllipsis">@last.ShortDescription</p>
                                    </div>
                            }
                            @*<div class="testNew">
                                <h2><a class="colortest1" href="#">@last.Title</a></h2>
                                <p>@last.ShortDescription</p>
                            </div>*@
                            <div class="clearfix"></div>
                        </li>
                        }
                    }

                </ul>
            </div>
            <div class="listN">
                <h2 class="h1Sibar">Popular Articles</h2>
                <ul class="listBlog">
                    @if (Model != null)
                    {
                        int i=1;
                        foreach (var item in Model)
                        {
                            string color = "colortest" + i;
                            i++;
                        <li>
                            @if( item.ImagePath != null)
                            {
                            <div class="imgBlog"><a href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(item.Title), id = item.NewsID })">
                                <div class="maskN"></div>
                                <img src="~/Images/News/@item.ImagePath" style="height:70px"></a></div>
                            <div class="testNew">
                                <h2><a class="@color" href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(item.Title), id = item.NewsID })">@item.Title</a></h2>
                                <p class="giveMeEllipsis">@item.ShortDescription</p>
                            </div>
                           
                            }
                            else
                            {
                                 <div class="testNewNon">
                                <h2><a class="@color" href="@Url.RouteUrl("News", new {title = WebSoftSeo.Utility.HelperSEO.ToSeoUrl(item.Title), id = item.NewsID })">@item.Title</a></h2>
                                <p class="giveMeEllipsis">@item.ShortDescription</p>
                            </div>
                          
                            }
                             <div class="clearfix"></div>
                        </li>
                        }
                    }

                </ul>
            </div>
            <div class="clearfix"></div>
            
        </div>
    </div>
</div>
<!-- End Content Blog -->
